﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
namespace Movie.DAL
{
   public class ScheduleDAL
    {
       public static List<Modal.Schedule> GetSchedule(int MovieId, int CinemaId, DateTime dt) 
       {
           List<Modal.Schedule> list = new List<Modal.Schedule>();
           string sql = string.Format("select * from Schedule where movieId='{0}' and ScheduleDate>='{1}' and RoomId in(select RoomId from Room where CinemaId='{2}')",MovieId,dt,CinemaId);
           SqlDataReader reder = sqlHelper2.ExcuteReader(sql);
           while (reder.Read())
           {  
               Modal.Schedule sc = new Modal.Schedule();
               sc.ScheduleID =Convert.ToInt32(reder["ScheduleID"]);
               sc.MovieId = Convert.ToInt32(reder["MovieId"]);
               sc.RoomID = Convert.ToInt32(reder["RoomID"]);
               sc.ScheduleDate = Convert.ToDateTime(reder["ScheduleDate"]);
               sc.StartTime = (TimeSpan) reder["StartTime"];
               sc.EndTime = (TimeSpan) reder["EndTime"];
               sc.Price = Convert.ToDecimal(reder["Price"]);
               list.Add(sc);
           }

           reder.Close();
           return list;
       
       }


    }
}
